<?php

class Cell
{
	private $value = 0;
	private $possibilities = array();
	private $position = -1;
	const MAX_VALUE = 10;
	
    public function __construct($position)
	{
		$this->position = $position;
		$this->initializeCell();
	}
	
	public function initializeCell()
	{
		$this->possibilities = $this->setupPossibilities();
	}
	
	public function setupPossibilities()
	{
		$tmp_poss = array();
		for($count =1; $count < Cell::MAX_VALUE; $count++)
		{
			$tmp_poss[] = $count;	
		}
		return $tmp_poss;
	}
	
	public function getPossibilities()
	{
		return $this->possibilities;
	}
	
	public function setValue($value)
	{
		$this->value = $value;
		$this->possibilities = array();
	}
	
	public function getValue()
	{
		return $this->value;
	}
	
	public function removeFromPossibilities($value)
	{
		if(in_array($value, $this->possibilities))
		{
			$result = array_search($value, $this->possibilities);
			$possible_value = $this->possibilities;
			unset($possible_value[$result]);
			$this->possibilities = array_values($possible_value);
		}
	}
	
	public function isPossible($value)
	{
		return in_array($value, $this->possibilities);
	}	
}